package controller

import (
	"github.com/gin-gonic/gin"
	"lab.com/biz"
	"lab.com/request"
)

type cPaper struct {
	APIBase
}

// Paper .
var Paper = cPaper{}

// Add return paper add
func (paper *cPaper) Add(c *gin.Context) {
	inputParams := request.PaperAddReq{}
	if err := inputParams.CheckInputParams(c); err != nil {
		paper.Resp(c, nil, err)
		return
	}

	err := biz.Paper.Add(c, inputParams)
	paper.Resp(c, nil, err)
}

// Edit return paper edit
func (paper *cPaper) Edit(c *gin.Context) {
	inputParams := request.PaperEditReq{}
	if err := inputParams.CheckInputParams(c); err != nil {
		paper.Resp(c, nil, err)
		return
	}

	err := biz.Paper.Edit(c, inputParams)
	paper.Resp(c, nil, err)
}

// Delete return paper delete
func (paper *cPaper) Delete(c *gin.Context) {
	inputParams := request.PaperDeleteReq{}
	if err := inputParams.CheckInputParams(c); err != nil {
		paper.Resp(c, nil, err)
		return
	}

	err := biz.Paper.Delete(c, inputParams)
	paper.Resp(c, nil, err)
}

// List return paper list
func (paper *cPaper) List(c *gin.Context) {
	inputParams := request.PaperListReq{}
	if err := inputParams.CheckInputParams(c); err != nil {
		paper.Resp(c, nil, err)
		return
	}

	out, err := biz.Paper.List(c, inputParams)
	if err != nil{
		paper.Resp(c, nil, err)
		return 
	}
	paper.Resp(c, out, err)
}

// Detail return paper detail
func (paper *cPaper) Detail(c *gin.Context) {
	inputParams := request.PaperDetailReq{}
	if err := inputParams.CheckInputParams(c); err != nil {
		paper.Resp(c, nil, err)
		return
	}

	out, err := biz.Paper.Detail(c, inputParams)
	if err != nil{
		paper.Resp(c, nil, err)
		return 
	}
	paper.Resp(c, out, err)
}

// TagAdd return paper tag add
func (paper *cPaper) TagAdd(c *gin.Context) {
	inputParams := request.TagAddReq{}
	if err := inputParams.CheckInputParams(c); err != nil {
		paper.Resp(c, nil, err)
		return
	}

	err := biz.Paper.TagAdd(c, inputParams)
	paper.Resp(c, nil, err)
}

// TagEdit return paper tag edit
func (paper *cPaper) TagEdit(c *gin.Context) {
	inputParams := request.TagEditReq{}
	if err := inputParams.CheckInputParams(c); err != nil {
		paper.Resp(c, nil, err)
		return
	}

	err := biz.Paper.TagEdit(c, inputParams)
	paper.Resp(c, nil, err)
}

// TagDelete return paper tag delete
func (paper *cPaper) TagDelete(c *gin.Context) {
	inputParams := request.TagDeleteReq{}
	if err := inputParams.CheckInputParams(c); err != nil {
		paper.Resp(c, nil, err)
		return
	}

	err := biz.Paper.TagDelete(c, inputParams)
	paper.Resp(c, nil, err)
}

// TagList return paper tag list
func (paper *cPaper) TagList(c *gin.Context) {
	inputParams := request.TagListReq{}
	if err := inputParams.CheckInputParams(c); err != nil {
		paper.Resp(c, nil, err)
		return
	}

	out, err := biz.Paper.TagList(c, inputParams)
	if err != nil{
		paper.Resp(c, nil, err)
		return 
	}
	paper.Resp(c, out, err)
}

// TagOption return paper tag option
func (paper *cPaper) TagOption(c *gin.Context) {
	out, err := biz.Paper.TagOption(c)
	if err != nil{
		paper.Resp(c, nil, err)
		return 
	}
	paper.Resp(c, out, err)
}